package org.cbg.panel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import org.cbg.btn.TrslationBtn;
import org.cbg.entity.Roleorder;
import org.cbg.mouslisten.CBGmoveMouslisten;
import org.come.until.CutButtonImage;
import org.come.until.FormsManagement;

import com.tool.tcpimg.UIUtils;

 

/**
 * 我的藏宝阁 我的订单Model面板
 * 
 * @author Administrator
 * 
 */
public class TraslationMyMainMyorderModelJpanel extends JPanel {
    // 订单号 展示底框 展示图标 大话币下 价格 单价
    private JLabel dingdanhao, zhanshidikuang, tupian, dahuabixia, danjia, price;

    // 购买button
    private TrslationBtn buy;

    // 是否被收藏标识(0表示被收藏，1表示没有被收藏)
    private int stateOrNo = 1;

    public TraslationMyMainMyorderModelJpanel() {
        this.setLayout(null);
        this.setPreferredSize(new Dimension(740, 62));
        this.setOpaque(false);


        dingdanhao = new JLabel("12312568411");
        tupian = new JLabel();
        zhanshidikuang = new JLabel();
        dahuabixia = new JLabel("四千八百万");
        danjia = new JLabel("48.6万两/元");

        zhanshidikuang.setBorder(null);
        zhanshidikuang.setBounds(38, 2, 53, 53);
        zhanshidikuang.setIcon(CutButtonImage.getImage("inkImg/number/b4/spbj.png", 53, 53));
        zhanshidikuang.setOpaque(false);
        this.add(zhanshidikuang);

        price = new JLabel("￥100.0");
        buy = new TrslationBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, UIUtils.TEXT_HY16, "购买");
        dahuabixia.setFont(UIUtils.TEXT_FONT1);
        dahuabixia.setForeground(UIUtils.COLOR_cbg3);
        danjia.setFont(UIUtils.TEXT_FONT2);
        danjia.setForeground(UIUtils.COLOR_cbg6);
        price.setFont(UIUtils.TEXT_FONT60);
        price.setForeground(UIUtils.COLOR_cbg4);

        dingdanhao.setBounds(2, 15, 70, 20);
        dingdanhao.setForeground(Color.white);
        dingdanhao.setFont(UIUtils.TEXT_FONT);
        tupian.setBounds(40, 5, 48, 48);
        dahuabixia.setBounds(100, 8, 135, 24);
        price.setBounds(200, 12, 125, 40);
        danjia.setBounds(360, 12, 125, 40);

        buy.setBounds(680, 15, 55, 27);
        buy.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                /**
                 * 打开购买详情界面
                 */
                FormsManagement.showForm(79);
            }
        });

        this.add(buy);
        this.add(dingdanhao);
        this.add(tupian);
        this.add(dahuabixia);
        this.add(danjia);
        this.add(price);
    }

    public TraslationMyMainMyorderModelJpanel(Roleorder roleorder) {
        this.setLayout(null);
        this.setPreferredSize(new Dimension(740, 62));
        this.setOpaque(false);
        dingdanhao = new JLabel(roleorder.getOrderid().toString());
//        dingdanhao.setHorizontalAlignment(SwingConstants.CENTER);
        tupian = new JLabel();
        zhanshidikuang = new JLabel();
        dahuabixia = new JLabel(roleorder.getSalename());
        danjia = new JLabel(roleorder.getSaleprice().toString());

        zhanshidikuang.setBorder(null);
        zhanshidikuang.setBounds(38, 2, 53, 53);
        zhanshidikuang.setIcon(CutButtonImage.getImage("inkImg/number/b4/spbj.png", 53, 53));
        zhanshidikuang.setOpaque(false);
        this.add(zhanshidikuang);

        price = new JLabel();
        buy = new TrslationBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_WHITE2, UIUtils.TEXT_HY16, "购买");
        // 状态（1未付钱 2超时 3已付钱 4已取货）
        switch (roleorder.getStatus()) {
            case 1:
                price.setText("未付钱");
                buy.setText("付 款");
                break;
            case 2:
                price.setText("超时");
                buy.setVisible(false);
                break;
            case 3:
                price.setText("已付钱");
                buy.setVisible(false);
                break;
            case 5:
                price.setText("已发货");
                buy.setVisible(false);
                break;
            case 4:
                price.setText("已取货");
                buy.setVisible(false);
                break;
            case 6:
                price.setText("待取回");
                buy.setVisible(false);
                break;
            case 7:
                price.setText("已取回");
                buy.setVisible(false);
                break;
            default:
                break;
        }
        dahuabixia.setFont(UIUtils.TEXT_FONT1);
        dahuabixia.setForeground(UIUtils.COLOR_cbg3);
        danjia.setFont(UIUtils.TEXT_FONT2);
        danjia.setForeground(UIUtils.COLOR_cbg6);
        price.setFont(UIUtils.TEXT_FONT60);
        price.setForeground(UIUtils.COLOR_cbg4);

        /**
         * 获取图片
         */
        tupian.setIcon(CutButtonImage.getCBG(roleorder.getSaletype(), roleorder.getSaleskin(), 48, 48));
        dingdanhao.setBounds(2, 12, 50, 40);
        dingdanhao.setForeground(UIUtils.COLOR_cbg6);
        dingdanhao.setFont(UIUtils.TEXT_FONT2);
        tupian.setBounds(40, 5, 48, 48);
        dahuabixia.setBounds(100, 8, 135, 24);
        danjia.setBounds(240, 12, 125, 40);
        price.setBounds(410, 12, 125, 40);

        buy.setBounds(680, 15, 59, 24);
        buy.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                // TODO Auto-generated method stub
                /**
                 * 打开购买详情界面
                 */
                FormsManagement.showForm(79);
            }
        });

        this.add(buy);
        this.add(dingdanhao);
        this.add(tupian);
        this.add(dahuabixia);
        this.add(danjia);
        this.add(price);

        /**
         * 添加展示面板
         */
        tupian.addMouseListener(new CBGmoveMouslisten(roleorder.getSaletype(), roleorder.getOtherid()));
    }

    private ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (icon == null) {
            icon = CutButtonImage.getImage("inkImg/old/1/Z1001.png", 740, 2);
        }
        g.drawImage(icon.getImage(), 0, 58, 740, 2, this);

        //Delete.Deletexcbg();



    }
}
